{extend name='admin@main'}

{block name="button"}

{if auth("add")}
<button data-modal='{:url("add")}' data-title="添加作业人员" class='layui-btn layui-btn-sm layui-btn-primary'>添加作业人员</button>
{/if}
{if auth("remove")}
<button data-action='{:url("remove")}' data-rule="id#{key}" data-csrf="{:systoken('remove')}"
    data-confirm="确定要删除这些作业人员吗？" class='layui-btn layui-btn-sm layui-btn-primary'>删除作业人员</button>
{/if}

{if auth("import")}
<a class="layui-btn layui-btn-sm layui-btn-warm" href="/static/file/import/人员信息导入模板.xlsx">下载导入模板</a>
<button type="button" class="layui-btn layui-btn-sm layui-btn-normal" id="upload" style="margin-right: 10px;">
    <i class="layui-icon">&#xe67c;</i>批量导入
</button>
{/if}

{if auth("export")}
<a class="layui-btn layui-btn-sm" href="{:url('index')}?{$_SERVER['QUERY_STRING']}&export=1">导 出</a>
{/if}

{/block}

{block name="content"}
<div class="think-box-shadow">
    {include file='user/index_search'}
    <table class="layui-table" lay-skin="line">
        {notempty name='list'}
        <thead>
            <tr>
                <th class='text-left nowrap'>姓名</th>
                <th class='text-left nowrap'>主体名称</th>
                <th class='text-center nowrap'>类型</th>
                <th class='text-center nowrap'>分类</th>
                <th class='text-center nowrap'>属性</th>
                <th class='text-center nowrap'>结算方式</th>
                <th class='text-center nowrap'>支付方式</th>
                <th class='text-left nowrap'>手机</th>
                <th class='text-left nowrap'>银行卡号</th>
                <th class='text-center nowrap'>使用状态</th>
                <th class='text-left nowrap'>添加时间</th>
                <th class='text-left nowrap'></th>
            </tr>
        </thead>
        {/notempty}
        <tbody>
            {foreach $list as $key=>$vo}
            <tr data-dbclick>
                <td class='text-left nowrap'>{$vo.name|default=''}</td>
                <td class='text-left nowrap'>{$vo.body_name|default='-'}</td>
                <td class='text-center nowrap'>
                    {eq name='vo.type' value='0'}<span class="layui-badge layui-bg-blue">运力</span>{/eq}
                    {eq name='vo.type' value='1'}<span class="layui-badge layui-bg-green">分拣</span>{/eq}
                </td>
                <td class='text-center nowrap'>
                    {eq name='vo.classify' value='0'}<span class="layui-badge layui-bg-blue">固定</span>{/eq}
                    {eq name='vo.classify' value='1'}<span class="layui-badge layui-bg-orange">临时</span>{/eq}
                </td>
                <td class='text-center nowrap'>
                    {eq name='vo.att' value='0'}<span class="layui-badge layui-bg-blue">车队</span>{/eq}
                    {eq name='vo.att' value='1'}<span class="layui-badge layui-bg-orange">个人</span>{/eq}
                    {eq name='vo.att' value='2'}<span class="layui-badge layui-bg-green">劳务</span>{/eq}
                    {eq name='vo.att' value='3'}<span class="layui-badge layui-bg-gray">自招</span>{/eq}
                </td>
                <td class='text-center nowrap'>
                    {eq name='vo.payment_way' value='0'}<span class="color-red">周结</span>{/eq}
                    {eq name='vo.payment_way' value='1'}<span class="color-green">月结</span>{/eq}
                    {eq name='vo.payment_way' value='2'}<span class="color-desc">无</span>{/eq}
                </td>
                <td class='text-center nowrap'>
                    {eq name='vo.pay_way' value='0'}<span class="color-red">灵活用工</span>{/eq}
                    {eq name='vo.pay_way' value='1'}<span class="color-green">银行转账</span>{/eq}
                    {eq name='vo.pay_way' value='2'}<span class="color-blue">线下支付</span>{/eq}
                </td>

                <td class='text-left nowrap'>{$vo.phone|default='-'}</td>
                <td class='text-left nowrap'>{$vo.bank_number|default='-'}</td>
                <td class='text-center nowrap'>
                    {if $vo.out_time}
                    <span class="color-desc">离职</span>
                    {else}
                    {eq name='vo.status' value='0'}<span class="color-red">已禁用</span>{/eq}
                    {eq name='vo.status' value='1'}<span class="color-green">正常</span>{/eq}
                    {/if}
                </td>
                <td class='text-left nowrap'>
                    {$vo.create_at|format_datetime}
                </td>
                <td class='text-left nowrap'>

                    {if auth("edit")}
                    <a data-dbclick class="layui-btn layui-btn-sm" data-title="编辑作业人员信息"
                        data-modal='{:url("edit")}?id={$vo.id}'>编 辑</a>
                    {/if}

                    {if auth("state") and $vo.status neq 0}
                    <a class="layui-btn layui-btn-sm layui-btn-warm" data-action="{:url('state')}"
                        data-value="id#{$vo.id};status#0" data-csrf="{:systoken('state')}">禁 用</a>
                    {elseif auth("state") and $vo.status neq 1 }
                    <a class="layui-btn layui-btn-sm layui-btn-warm" data-action="{:url('state')}"
                        data-value="id#{$vo.id};status#1" data-csrf="{:systoken('state')}">启 用</a>
                    {/if}

                    {if auth("remove")}
                    <a class="layui-btn layui-btn-sm layui-btn-danger" data-confirm="确定要删除该成员吗？"
                        data-action="{:url('remove')}" data-value="id#{$vo.id}" data-csrf="{:systoken('remove')}">删
                        除</a>
                    {/if}

                </td>
            </tr>
            {/foreach}
        </tbody>
    </table>

    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}

</div>
<script>
    layui.use('upload', function () {
        var upload = layui.upload;
        //执行实例
        var uploadInst = upload.render({
            elem: '#upload' //绑定元素
            , url: "{:url('import')}" //上传接口
            , method: 'POST'
            , accept: 'file'//指定允许上传时校验的文件类型，可选值有：images（图片）、file（所有文件）、video（视频）、audio（音频）
            , exts: 'xlsx|xls'//只允许上传excel文件,未设定，那么限制的就是图片的文件格式
            , before: function (obj) { //obj参数包含的信息，跟 choose回调完全一致，可参见上文。
                layer.load(); //上传loading            
            }
            , done: function (res) {
                layer.closeAll('loading'); //关闭loading
                //上传完毕回调
                console.log(res)
                if (res.code == 1) {
                    layer.open({
                        title: '导入结果'
                        , content: res.msg
                        , btn: ['确定']
                        , yes: function (index, layero) {
                            location.reload();//刷新单前页
                        }
                    });
                } else {
                    layer.msg(res.msg, { icon: 5 });
                }
            }
        });
    });

</script>

{/block}